import React from 'react';
import * as asyncLoad from '../util/asyncLoad';
import { workflowPublicFiles } from '../constants/fileConfig';
import Loading from './Loading';

export default class RelatedWorkflow extends React.Component{
    constructor(){
        super();
        this.state = {
            hasLoad: false,
            store: null
        };
    }
    componentDidMount(){
        const init = () =>{
            const { RelatedWorkflowStore } = window.weaWorkflowPublic;
            const store = new RelatedWorkflowStore();
            this.setState({hasLoad:true, store:store});
        }
        asyncLoad.asyncLoadModule('workflowPublic', workflowPublicFiles, init);
    }
    render(){
        const { hasLoad,store } = this.state;
        if(hasLoad){
            const { commonParam } = this.props;
            const { RelatedWorkflow } = window.weaWorkflowPublic;
            return (
                <RelatedWorkflow ecId={`${this && this.props && this.props.ecId || ''}_WfFormResourceCom@ks9ly1`} wfFormResourceStore={store} commonParam={commonParam} />
            )
        }else{
            return (<Loading ecId={`${this && this.props && this.props.ecId || ''}_Loading@i7q8kt`} />);
        }
    }
}